-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nexus fix: OwnableValidator & OwnableExecutor integration + tests, + add missing features after viem refactor + fix issues & conflicts +++ #576
Conversation
conflicts need to be resolved. |
import type { Module } from "../utils/Types.js" | ||
|
||
export class OwnableValidator extends BaseValidationModule { | ||
public smartAccount: NexusSmartAccount |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it useful for all modules' instances to get SA instance passed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, since we are building user operations for module transactions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, my only concern was regarding applying defaultValidatorModule when first time SA instance is created and module will expect SA instance passed.
parseAbiParameters("uint256 threshold, address[] owners"), | ||
moduleConfig.data | ||
) | ||
super(moduleConfig, smartAccount.getSmartAccountOwner()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't super supposed to accept a signer?
private constructor(moduleConfig: Module, signer: SmartAccountSigner) {
super(moduleConfig, signer)
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's what smartAccount.getSmartAccountOwner() is passing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok I thought by name it returns an address and not signer object.
public threshold: number | ||
|
||
private constructor( | ||
moduleConfig: Module, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Module has become a multi-purpose type. have some questions around it, as data can be interpreted multiple ways when it comes to installations and uninstallation if I'm not wrong?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You propose to create specific types for each module ? Like instead of having "Module" we would have "OwnableValidatorModuleConfig" ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is fine for now if only common properties are mandatory
smartAccount: NexusSmartAccount, | ||
owners: Address[], | ||
threshold?: number, | ||
hook?: Address |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder what is the purpose of this. have noticed in module-sdk as well where a hook is always tied to any kind of a module..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is for Kernel modules, Kernel has a hook that is associated with every validator, executor and fallback
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see
hook?: Address | ||
): Promise<OwnableValidator> { | ||
if ( | ||
!owners.includes(await smartAccount.getSmartAccountOwner().getAddress()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we're assuming here already initialised smart account. MUST be initialised with K1 as default
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but what if I had passed defaultValidationModule as PasskeyValidator instance in the future? generally how does smartAccount.getSmartAccountOwner() give you answer and fit with .getAddress() later.
just food for thought
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't get this, need more context
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
specific to nexus account. if default validator module is different then this would not have expected result
if ( | ||
!owners.includes(await smartAccount.getSmartAccountOwner().getAddress()) | ||
) { | ||
throw Error("Signer needs to be one of the owners") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you mean one of the owners should also be an onwer through K1 validator module assumed to be installed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, my initial thought was that we need the smart account owner eoa to be part of this owners array too but it does not, I did some changes to fix this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup. could be totally unrelated owners
data: calldata, | ||
value: 0n | ||
} | ||
const userOp = await this.smartAccount.buildUserOp([transaction]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see benefit of passing smartAccount instance is userop can be sent right away. in stead of just requesting for calldata
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly, we add a new layer of utility to the module instance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
review i
conflicts to be resolved |
…-sdk into nexus_fix/ownableValidator
size-limit report 📦
|
ok new conflicts here |
…-sdk into nexus_fix/ownableValidator
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great to have install functionality back. Thanks for bringing it back 💪
Just a wider point on our modules. I don't like the folder structure any more. It's difficult to know where to look or why the folders are arranged in the way that they are. I also don't like the Base class stuff that we have now. It feels dated, and I'm not sure it even makes sense given how much variety we will have from our modules. I prefer rhinestone flatter / simplified way of organising modules. Can we replicate something similar to what they have done, paired with decorators that can be extended by a nexusClient instead? I realise this might require a different PR |
checks are failing. |
We don't need this, instead we will be migrating to use rhinestone's sdk for module. |
const defaultedActiveModule = | ||
activeModule ?? | ||
let defaultedActiveModule = | ||
activeValidationModule ?? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can also call this activeValidator
but can keep this as note for now and still merge PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
leaving approved
PR-Codex overview
This PR focuses on refactoring the handling of
signer
instead ofholder
in various modules and updates the related tests. It also introduces new functionalities and makes structural adjustments to improve the codebase.Detailed summary
holder
withsigner
in multiple files.toHolder
utility totoSigner
.Signer
.getPreviousModule
for retrieving previous module addresses.OwnableExecutor
andOwnableValidator
.package.json
dependencies.addresses.ts
.